# _*_ coding : utf-8 _*_
# @Time : 2023/8/26 21:03
# @Author : 寻梦
# @File : ipapi
# @Project : code
import base64
import json
import urllib.request
import urllib.parse
# 获取ip信息
base_url="https://dps.kdlapi.com/api/getdps/?"

userinfo={
    "username":"d1278438791",
    "password":"ce7ywtoe"
}
headers={
    "Proxy-Authorization":base64.b64encode(bytes(userinfo["username"]+":"+userinfo["password"],encoding="utf8")).decode()
}



def getApis(numbers):
    # 创建请求对象
    param={
        "secret_id": "oazd1iis9vwsvdj5lm9i",
        "num" : 10 ,
        "signature" : "lr82rf7y68tzudm1o2ctcgpr47vbbi2w",
        "pt" : 1,
        "format" : "json",
        "sep":1
    }
    param["num"]=numbers
    request = urllib.request.Request(url=base_url+urllib.parse.urlencode(param), headers=headers)
    response= urllib.request.urlopen(request)
    content= response.read().decode('utf8')
    res=json.loads(content)
    if res["code"]==0:
        return res["data"]["proxy_list"]
    else:
        print("获取数据异常")
        return []